package com.shiyi.design.singleton;

/**
 * 饿汉式-静态代码块
 *
 * @Author qiu
 * @Date 2021/1/10 23:09
 */
public class SingletonDesignModel2 {
    private static final SingletonDesignModel2 INSTANCE;
    static {
        INSTANCE = new SingletonDesignModel2();
    }

    private SingletonDesignModel2(){};

    public static SingletonDesignModel2 getInstance() {
        return INSTANCE;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            new Thread(() -> System.out.println(getInstance().hashCode())).start();
        }
    }
}
